<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class MenuPanel {
    var $id;
var $menu_caption;
var $menu_icon;
var $menu_url;
var $menu_desc;
var $menu_admin;
var $parent_id;


    function open(){
        global $db;
        $sql="select * from _menu_panel where id={$this->id}";
        $row=$db->fetch_row($sql);
        if (!empty($row)){
            extract($row);
            $this->menu_caption=$menu_caption;
$this->menu_icon=$menu_icon;
$this->menu_url=$menu_url;
$this->menu_desc=$menu_desc;
$this->menu_admin=$menu_admin;
$this->parent_id=$parent_id;

        }
    }

    function openAll(){
        $sql="select * from _menu_panel order by id asc";
        $result=$db->query($sql);
        return $db->fetch_array($result);
        
    }

    function insert(){
    global $db;
    $sql="insert into _menu_panel values (null,'{$this->menu_caption}',
'{$this->menu_icon}',
'{$this->menu_url}',
'{$this->menu_desc}',
'{$this->menu_admin}',
'{$this->parent_id}')";
    $db->query($sql);
    return mysql_insert_id();
    }

    function update(){
        global $db;
        $sql="update _menu_panel set menu_caption='{$this->menu_caption}',
            menu_icon='{$this->menu_icon}',
            menu_url='{$this->menu_url}',
            menu_desc='{$this->menu_desc}',
            menu_admin='{$this->menu_admin}',
            parent_id={$this->parent_id}
            where id=".$this->id;
        $db->query($sql);
    }

    function delete(){
        global $db;
        $sql="delete from _menu_panel where id=".$this->id;
        $db->query($sql);
    }

}
?>
